package com.mashibing.tank.strategy;

import com.mashibing.tank.Bullet;
import com.mashibing.tank.Dir;
import com.mashibing.tank.Player;
import com.mashibing.tank.TankFrame;

/**
 * @description:
 * @author: 余希瑶
 * @date: 2021年06月22日 12:13
 * @version:1.0
 */
public class FourDirFireStrategy implements FireStrategy {
    @Override
    public void fire(Player p) {

        int bX = p.getX() + Player.WIDTH / 2 - Bullet.WIDTH / 2;
        int bY = p.getY() + Player.HEIGHT / 2 - Bullet.HEIGHT / 2;

        Dir[] dirs = Dir.values();

        for (Dir d : dirs) {
            TankFrame.INSTANCE.getGm().add(new Bullet(bX, bY, d, p.getGroup()));
        }
    }
}
